package com.tentact.servlets;

import com.tentact.service.MeetingService;
import com.tentact.vo.MeetingRoom;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "UpdateMeetingRoomServlet", value = "/UpdateMeetingRoomServlet")
public class UpdateMeetingRoomServlet extends HttpServlet {
    private MeetingService service = new MeetingService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int roomid = Integer.parseInt(request.getParameter("roomid"));
        String roomcode = request.getParameter("roomcode");
        String roomname = request.getParameter("roomname");
        int roomcapacity = Integer.parseInt(request.getParameter("roomcapacity"));
        int status = Integer.parseInt(request.getParameter("status"));
        String description = request.getParameter("description");
        System.out.println(roomid);
        System.out.println(roomcode);
        System.out.println(roomname);
        System.out.println(roomcapacity);
        System.out.println(status);
        System.out.println(description);
        MeetingRoom meetingRoom = new MeetingRoom(roomid,roomcode,roomname,roomcapacity,status,description);
        if (service.updateMeetroom(meetingRoom)==1) {
            System.out.println("成功");
        } else {
            System.out.println("失败");
        }
        System.out.println(meetingRoom.getRoomid());
        System.out.println(meetingRoom.getRoomcode());
        System.out.println(meetingRoom.getRoomname());
        System.out.println(meetingRoom.getRoomcapacity());
        System.out.println(meetingRoom.getRoomstatus());
        System.out.println(meetingRoom.getDescription());
        request.getRequestDispatcher("SelectMeetingRoomsServlet").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
